#pragma once

#include <QPropertyAnimation>
#include <QWidget>

class FlyWidget : public QWidget {
    Q_OBJECT
public:
    enum {
        LeftClick,
        RightClick,
        LeftDoubleClick,
        LinkClick,
    };
    explicit FlyWidget(QString str, QWidget* parent = nullptr);

protected:
    void paintEvent(QPaintEvent* e) override;
    QSize sizeHint() const override;  // 提供推荐大小
    void showEvent(QShowEvent* e) override;
#if (QT_VERSION <= QT_VERSION_CHECK(6, 0, 0))
    void enterEvent(QEvent* e) override;
#else
    void enterEvent(QEnterEvent*) override;
#endif
    void leaveEvent(QEvent* e) override;
    void mousePressEvent(QMouseEvent* e) override;

signals:
    void clicked(QString word, int type, QPoint pos);

private:
    QPoint m_start;
    QPropertyAnimation* m_anm;
    QString m_str;
    QColor m_bg;
    int m_margin = 10;
};
